/*弹出层*/
/*
 参数解释：
 title	标题
 url		请求的url
 id		需要操作的数据id
 w		弹出层宽度（缺省调默认值）
 h		弹出层高度（缺省调默认值）
 */
function layer_show(title, url, w, h) {
	if (title == null || title == '') {
		title = false;
	}
	if (url == null || url == '') {
		url = "404.html";
	}
	if (w == null || w == '') {
		w = 800;
	}
	if (h == null || h == '') {
		h = ($(window).height() - 50);
	}
	var index = layer.open({
		type: 2,
		area: [w + 'px', h + 'px'],
		fix: false, //不固定
		maxmin: true,
		shade: 0.4,
		title: title,
		content: url
	});
	layer.full(index);
}

function layer_show_min(title, url, w, h) {
	if (title == null || title == '') {
		title = false;
	}
	if (url == null || url == '') {
		url = "404.html";
	}
	if (w == null || w == '') {
		w = 800;
	}
	if (h == null || h == '') {
		h = ($(window).height() - 50);
	}
	layer.open({
		type: 2,
		area: [w + 'px', h + 'px'],
		fix: false, //不固定
		maxmin: true,
		shade: 0.4,
		title: title,
		content: url
	});
}

function layer_show_btn(title, url, w, h) {
	if (title == null || title == '') {
		title = false;
	}
	if (url == null || url == '') {
		url = "404.html";
	}
	if (w == null || w == '') {
		w = 400;
	}
	if (h == null || h == '') {
		h = ($(window).height() - 100);
	}

	var index=layer.open({
		type: 2,
		area: [w + 'px', h + 'px'],
		fix: false, //不固定
		maxmin: true,
		shade: 0.4,
		title: title,
		content: url,
		btn: ['关闭'],
		// yes: function(index,layero){
		// 	// var node = ztree.getSelectedNodes();
		// 	// //选择上级菜单
		// 	// vm.menu.parentId = node[0].menuId;
		// 	// vm.menu.parentName = node[0].name;
		//
		// 	layer.close(index);
		// },
		cancel: function(index){
			layer.close(index);
		}
	});
}

/*关闭弹出框口*/
function layer_close() {
	var index = parent.layer.getFrameIndex(window.name);
	parent.layer.close(index);
}



//获取当前 layer 中的iframe
function getIframe(layero){
	//获取iframe对象id
	var frameName = layero.find('iframe')[0]['name'];
	//获取iframe对象
	var iframeWin = window[frameName];
	return iframeWin;
}
/**
 * 弹出窗口
 * @param title
 * @param url
 * @param buttons  窗口按钮数组
 * @param functions 按钮对应的函数对象{btn1:function(){},btn2:function(){}}
 */
function popWindow(title, url, buttons, functions, styleConfig) {
	if (title == null || title == '') {
		title = false;
	}
	if (url == null || url == '') {
		url = "404.html";
	}
	var config = {
		type: 2,
		area: ['500px', '400px'],
		fix: false, //不固定
		maxmin: true,
		shade: 0.4,
		title: [
			title,
			'font-weight:bold;'
		],
		content: url
	};
	if (buttons != null && buttons.length > 0) {
		config.btn = buttons;
	}
	if (functions != null) {
		$.each(functions, function (n, value) {
			var prop = n;
			config[prop] = value;
		});
	}

	if (styleConfig != null) {
		$.each(styleConfig, function (n, value) {
			var prop = n;
			config[prop] = value;
		});
	}
	var index = layer.open(config);
	layer.full(index);
}

/**
 * 弹出窗口
 * @param title
 * @param url
 * @param buttons  窗口按钮数组
 * @param functions 按钮对应的函数对象{btn1:function(){},btn2:function(){}}
 */
function popWindowMin(title, url, buttons, functions, styleConfig) {
	if (title == null || title == '') {
		title = false;
	}
	if (url == null || url == '') {
		url = "404.html";
	}
	var config = {
		type: 2,
		area: ['500px', '500px'],
		fix: true, //不固定
		maxmin: true,
		shade: 0.4,
		title: [
			title,
			'font-weight:bold;'
		],
		content: url
	};
	if (buttons != null && buttons.length > 0) {
		config.btn = buttons;
	}
	if (functions != null) {
		$.each(functions, function (n, value) {
			var prop = n;
			config[prop] = value;
		});
	}

	if (styleConfig != null) {
		$.each(styleConfig, function (n, value) {
			var prop = n;
			config[prop] = value;
		});
	}
	var index = layer.open(config);
}